package com.syq.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.syq.pojo.CheckNull;
import com.syq.pojo.CheckType;
import lombok.Data;
import lombok.ToString;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

/**
 * @author Sun Yueqi
 * @version 1.00
 * @time 2022/5/25 20:27
 */
@Data
@ToString
public class UserDto implements CheckNull {
    private String username;
    private String password;
    private String name;
    private String phone;
    private String email;
    private Long sex;
    private String avator;
    private String info;

    @Override
    public boolean isEmpty(CheckType type) {
        switch (type){
            case ADD :
                return !StringUtils.hasText(username)
                        || !StringUtils.hasText(password)
                        || !StringUtils.hasText(name)
                        || !StringUtils.hasText(phone)
                        || !StringUtils.hasText(email)
                        || (ObjectUtils.isEmpty(sex)||(!sex.equals(1L)&&!sex.equals(2L)));
        }
        return false;
    }
}
